package com.aaa.gs;

import com.aaa.gs.config.MyRule;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableEurekaClient
@MapperScan("com.aaa.gs.dao")
@EnableTransactionManagement
//RibbonClient ribbon 客户端配置  name指定名称 configuration 指定负载均衡策略配置类
@RibbonClient(name = "goodsRibbonClient",configuration = MyRule.class)
public class GoodsApp {
    public static void main(String[] args) {
        SpringApplication.run(GoodsApp.class,args);
    }

    @Bean
    @LoadBalanced  //在使用restTemplate远程调用方式    使用负载均衡策略
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
}
